package com.jinghong.registerlogin.controller;

import com.jinghong.registerlogin.model.dto.PaperDTO;
import com.jinghong.registerlogin.model.dto.UpdatePaperDTO;
import com.jinghong.registerlogin.model.pojo.*;
import com.jinghong.registerlogin.model.vo.PaperVO;
import com.jinghong.registerlogin.service.PaperQuestionService;
import com.jinghong.registerlogin.service.PaperService;
import com.jinghong.registerlogin.service.QuestionService;
import com.jinghong.registerlogin.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.ArrayList;
import java.util.List;

/**
 * ClassName:AdminController
 * Package:com.jinghong.registerlogin.controller
 * Description:
 *
 * @Author: 寻月君子
 * @CreatTime:2024/5/30 11:14
 * Version:1.0
 */
@RestController
@RequestMapping("/admin")
public class AdminController {
    @Autowired
    private PaperService paperService;
    @Autowired
    private PaperQuestionService paperQuestionService;
    @Autowired
    private QuestionService questionService;
    @Autowired
    private UserService userService;

    @PutMapping("/updatePaperStatus")
    public Result updatePaperStatus(Integer id,Integer status){
        paperService.updateStatus(id,status);
        return Result.success();
    }


    @DeleteMapping("/deletePaper")
    public  Result deletePaper(Integer id){
        paperService.delete(id);
        return Result.success();
    }


    @DeleteMapping("/deleteQuestion")
    public  Result deleteQuestion(UpdatePaperDTO updatePaperDTO){
        paperService.deleteQuestion(updatePaperDTO);
        return Result.success();
    }


    @GetMapping("/getPaper")
    public Result getPaper(Integer id) {
        return Result.success(paperService.getIntirePaper(id));
    }

    @PutMapping("/updateUserLimit")
    public Result updateUserLimit(Integer userId,Integer isAdmin){
        userService.updateIsAdmin(userId,isAdmin);
        return Result.success();
    }

}
